package com.lms.logisticsmanagementsystem.service.Impl;

import com.lms.logisticsmanagementsystem.mapper.OrderMapper;
import com.lms.logisticsmanagementsystem.model.Order;
import com.lms.logisticsmanagementsystem.model.PS;
import com.lms.logisticsmanagementsystem.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderMapper orderMapper;

    @Override
    public List<Order> getOrderInfo() {
        List<Order> list = orderMapper.getOrderInfo();
        return list;
    }

    @Override
    public boolean addOrderInfo(Order order) {
        Integer flag = orderMapper.addOrderInfo(order);
        if (flag == 1) {
            return true;
        } else return false;
    }

    @Override
    public Order getOrderInfoById(Integer id) {
        Order order = orderMapper.getOrderInfoById(id);
        return order;
    }

    @Override
    public boolean updateOrderInfoById(Order order) {
        Integer flag = orderMapper.updateOrderInfoById(order);
        if (flag == 1) {
            return true;
        } else return false;
    }

    @Override
    public boolean generateOrder(Integer id) {
        Integer flag = orderMapper.generateOrder(id);
        if (flag == 1) {
            return true;
        } else return false;
    }

    @Override
    public boolean addPSInfo(PS ps) {
        Integer flag = orderMapper.addPSInfo(ps);
        if (flag == 1) {
            return true;
        } else return false;
    }

    @Override
    public boolean delOrderInfoById(Integer oid) {
        Integer flag = orderMapper.delOrderInfoById(oid);
        if (flag == 1) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public List<PS> getPSInfo() {
        List<PS> list = orderMapper.getPSInfo();
        return list;
    }

    @Override
    public boolean updatePSInfoStatusByPSBH(String psbh, String shtime) {
        Integer flag = orderMapper.updatePSInfoStatusByPSBH(psbh,shtime);
        if (flag==1)
            return true;
        else return false;
    }

    @Override
    public boolean delPSInfoByPSBH(String psbh) {
        Integer flag = orderMapper.delPSInfoByPSBH(psbh);
        if (flag==1){
            return true;
        }
        else return false;
    }

    @Override
    public List<PS> getPSInfoByPSTip(String pstip) {
        List<PS> list = orderMapper.getPSInfoByPSTip(pstip);
        return list;
    }

    @Override
    public List<Order> getOrderInfoByOTip(String otip) {
        List<Order> list = orderMapper.getOrderInfoByOTip(otip);
        return list;
    }
}
